package com.social.controller;

import com.alibaba.fastjson.JSON;
import com.social.pojo.AuditNcmForm;
import com.social.service.AuditNcmFormService;
import com.social.util.JsonUtil;
import com.social.util.StatusUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 已发送稽核通知案件管理
 */
@Controller
@RequestMapping("AuditNcmFormController")
public class AuditNcmFormController {
    /**
     * AuditNcmForm 业务层对象
     */
    @Autowired
    private AuditNcmFormService auditNcmForm;

    /**
     * 查所有
     *
     * @param session 作用域
     * @return 页面跳转状态
     */
    @RequestMapping("selectAll")
    public String status(HttpSession session, Integer status) {
        List<AuditNcmForm> auditNcmForms = auditNcmForm.selectAll();
        session.setAttribute("datas", auditNcmForms);
        return StatusUtil.statusYe(status);
    }

    /**
     * 录入缴费基数
     *
     * @param id            auditNcmForm primary key
     * @param baseOfPayment 缴费基数
     * @return 修改状态
     */
    @RequestMapping("update")
    @ResponseBody
    public String update(Integer id, Integer baseOfPayment) {
        //调用修改方法
        int status = auditNcmForm.updateByRegistrationOfCasesIdSelective(id, null, baseOfPayment);
        //调用返回数据
        JsonUtil jsonUtil = new JsonUtil();
        //设置状态
        Boolean restates = jsonUtil.getRestates(status);
        return JSON.toJSONString(restates);
    }

    /**
     * 查询单个数据
     *
     * @param registrationOfCasesId registrationOfCases primary key
     * @return AuditNcmForm 对象
     */
    @RequestMapping("selectByRegistrationOfCasesId")
    @ResponseBody
    public String selectByRegistrationOfCasesId(Integer registrationOfCasesId) {
        AuditNcmForm auditNcmForm = this.auditNcmForm.selectByRegistrationOfCasesId(registrationOfCasesId);
        return JSON.toJSONString(auditNcmForm);
    }
}
